using System;

namespace Crainiate.Data.Persistence
{
	[AttributeUsage(AttributeTargets.Property)]
	public class ColumnAttribute: Attribute, IColumnAttribute
	{

	}

	[AttributeUsage(AttributeTargets.Property)]
	public class PrimaryKeyAttribute: ColumnAttribute, IPrimaryKeyColumnAttribute
	{

	}

    [AttributeUsage(AttributeTargets.Property)]
    public class IdentityAttribute : ColumnAttribute, IIdentityColumnAttribute
    {
        private int _start;
        private int _increment;

        public IdentityAttribute(int start)
        {
            _start = start;
            _increment = 1;
        }

        public IdentityAttribute(int start, int increment)
        {
            _start = start;
            _increment = increment;
        }

        public int Start
        {
            get
            {
                return _start;
            }
        }

        public int Increment
        {
            get
            {
                return _increment;
            }
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public class CompoundKeyAttribute: ColumnAttribute, ICompoundKeyColumnAttribute
    {
        private int _rank;

        public CompoundKeyAttribute(int rank)
        {
            if (rank < 0) throw new PersistenceException("Rank must be greater than or equal to zero.");
            _rank = rank;
        }

        public int Rank
        {
            get
            {
                return _rank;
            }
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public class ForeignKeyAttribute: ColumnAttribute, IForeignKeyColumnAttribute 
    {
        private Type _references;

        public ForeignKeyAttribute(Type references)
        {
            _references = references;
        }

        public Type References
        {
            get
            {
                return _references;
            }
        }
    }
}
